#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    string a, b, c;
    char pairs[32] = { 0 }, mparis[32];
    int i, index;

    getline(cin, a);
    getline(cin, b);
    getline(cin, c);


    if (a.size() != b.size())
    {
        cout << "Failed";
        return 0;
    }

    for (i = 0; i < a.size(); i++)
    {
        index = b[i] - 'A';

        if (pairs[index] != 0 && pairs[index] != a[i])
        {
            cout << "Failed";
            return 0;
        }
        
        pairs[index] = a[i];
    }

    for (i = 0; i < 26; i++)
    {
        if (pairs[i] == 0)
        {
            cout << "Failed";
            return 0;
        }
    }
    
    for (i = 0; i < 26; i++)
    {
        mparis[pairs[i] - 'A'] = 'A' + i;
    }

    for (i = 0; i < c.size(); i++)
    {
        index = c[i] - 'A';
        cout << mparis[index];
    }

    return 0;
}
